# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=archinfo
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=9.2.157
pkgrel=1
pkgdesc="Classes with architecture-specific information useful to other projects (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/angr/archinfo"
msys2_references=(
  'purl: pkg:pypi/archinfo'
)
license=('spdx:BSD-2-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
)
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
optdepends=(
  "${MINGW_PACKAGE_PREFIX}-python-capstone"
  "${MINGW_PACKAGE_PREFIX}-python-unicorn"
  "${MINGW_PACKAGE_PREFIX}-python-keystone"
  "${MINGW_PACKAGE_PREFIX}-python-pyvex"
)
source=("${url}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha512sums=('840843eb82e77208e3b55c2e3f59d99616e7f28b93a3f1eaefd5762ffbd29e6eacea6e6f651584d8246428cef8bec0997a65ecbf18bfe96cdf4b11133f548ee0')


build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "python-build-${MSYSTEM}"

  python -m pytest
}

package() {
  cd "python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
  install -Dm644 README.md "${pkgdir}${MINGW_PREFIX}/share/doc/python-${_realname}/README.md"
}

